{% extends "layout.html" %}
{% block body %}
    <br>
<div class="am-container am-g">
    <div class="am-u-sm-12">
        <table class="am-table">
            <thead>
                <tr>
                    <th>编号</th>
                    <th>题目名称</th>
                    <th>状态</th>
                    <th>分数</th>
                    <th>总时间</th>
                    <th>提交者</th>
                    <th>提交时间</th>
                </tr>
            </thead>
            <tbody>
                {% set see_result=judge.is_allowed_see_result(user) %}
                {% set result=judge.get_result()%}
                <tr>
                    <td>{{judge.id}}</td>
                    <td><a href="{{url_for('problem',problem_id=judge.problem.id)}}">{{judge.problem.title}}</a></td>
                    {% if see_result %}
                    <td>{{result["status"]}}</td>
                    <td>{{result["score"]}}</td>
                    <td>{{result["total_time"]}}</td>
                    {% else %}
                    <td>隐藏</td>
                    <td>隐藏</td>
                    <td>隐藏</td>
                    {% endif %}
                    <td>{{judge.user.nickname}}</td>
                    <td>{{tool.pretty_time(judge.submit_time)}}</td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="am-u-sm-12">
        {% set see_code = judge.is_allowed_see_code(user) %}
        {% if see_code%}
        <pre><code>{{judge.code}}</code></pre>
        {% else %}
        <pre><code>=。=现在不可以看代码！</code></pre>
        {% endif %}
    </div>
    {% if see_code and see_result%}
    {% if result["status"] == "Compile Error" and result["compiler_output"] %}
    <div class="am-u-sm-12">
        <pre><code>{{result["compiler_output"]}}</code></pre>
    </div>
    {% else %}
    <div class="am-u-sm-12">
        <section class="am-accordion am-accordion-default">
            {% for i in range(result["case_num"]) %}
        <dl class="am-accordion-item">
            {% set case = result[tool.to_str(i)]%}
            <dt class="am-accordion-title" onclick="toggle_dd(this)">测试点:{{i + 1}} 状态:{{case["status"]}}
                运行时间:{{case["time_used"]}}ms 使用内存:{{case["memory_used"]}}kb
            </dt>
            <dd class="am-accordion-content am-collapse">
                <div class="am-accordion-content">
                    <strong>输入文件</strong>
                    <pre><code>{{case["input"]}}</code></pre>
                    <strong>期望输出</strong>
                    <pre><code>{{case["answer"]}}</code></pre>
                    <strong>你的输出</strong>
                    <pre><code>{{case["user_out"]}}</code></pre>
                </div>
            </dd>
        </dl>
        {% endfor %}
        </section>
    </div>
    {% endif %}
    {% endif %}
</div>
{% endblock %}

{% block script %}
<script type="text/javascript">
//Maybe the bug of Amaze or zishi of mine,the panel data can't been unfloded.
//I only able to solve it by this way.
function toggle_dd(dt){
    dd=$(dt).next();
    dd.toggle();
}
</script>
{% endblock %}
